package com.example.demo.order.controller;

import com.example.demo.order.OrderDto;
import com.example.demo.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping
@RestController
public class OrderController {

    @Autowired
    OrderService orderService;

    @GetMapping
    public ResponseEntity<OrderDto> createOrder(@RequestParam("uid") String userId, @RequestParam("pid") String productId) {
        OrderDto orderDto = orderService.createOrder(userId, productId);
        return ResponseEntity.ok(orderDto);
    }

}
